package com.example.moneybook.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.moneybook.dto.ResponseResult;
import com.example.moneybook.enums.AppHttpCodeEnum;
import com.example.moneybook.mapper.FeedbackMapper;
import com.example.moneybook.pojo.Feedback;
import com.example.moneybook.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author: 包
 * @Date: 2023/3/18 13:22
 * Description:
 */
@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements FeedbackService {

    @Autowired
    private FeedbackMapper feedbackMapper;

    @Override
    public ResponseResult addFeedback(Feedback feedback) {
        feedback.setFeedbackDate(new Date());
        int res = feedbackMapper.insert(feedback);
        if (res == 0){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID, "添加失败");
        }else {
            return ResponseResult.okResult(200, "添加成功");
        }
    }
}
